package com.ny.until;

import java.sql.*;

public class DbUntil {
    private static final String URL = "jdbc:mysql://localhost:3306/usersdb";
    private static final String DB_USERNAME = "root";
    private static final String DB_PASSWORD = "123456";
    public Connection getCon() throws SQLException, ClassNotFoundException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection conn = DriverManager.getConnection(URL, DB_USERNAME, DB_PASSWORD);

        return conn;
    }
    // 在原有的getCon方法基础上添加关闭资源的方法
    public void closeResources(Connection conn, PreparedStatement stmt, ResultSet rs) throws SQLException {
        if (rs != null) rs.close();
        if (stmt != null) stmt.close();
        if (conn != null) conn.close();
    }

}
// 在原有的getCon方法基础上添加关闭资源的方法

